#include <QQmlApplicationEngine>
#include <systemtray.h>
#include <localconfig.h>
#include <remotedatabase.h>
#include <localdatabase.h>
#include <clipboardhandler.h>
#include <QQmlContext>

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    // 注册 SystemTray 类到 QML
    qmlRegisterType<SystemTray>("com.example.tray", 1, 0, "SystemTray");
    qmlRegisterType<LocalConfig>("com.example.localConfig", 1, 0, "LocalConfig");
    qmlRegisterType<RemoteDataBase>("com.example.remoteDataBase", 1, 0, "RemoteDataBase");
    qmlRegisterType<LocalDataBase>("com.example.localDataBase", 1, 0, "LocalDataBase");

    QQmlApplicationEngine engine;
    ClipboardHandler clipboardHandler;
    engine.rootContext()->setContextProperty("clipboardHandler",  &clipboardHandler);

    QObject::connect(
        &engine,
        &QQmlApplicationEngine::objectCreationFailed,
        &app,
        []() { QCoreApplication::exit(-1); },
        Qt::QueuedConnection);
    engine.loadFromModule("ExperienceLife", "Main");

    return app.exec();
}
